package com.example.musicbox.controller;


import com.example.musicbox.entity.MComment;
import com.example.musicbox.service.impl.MCatalogueServiceImpl;
import com.example.musicbox.service.impl.MCommentServiceImpl;
import com.example.musicbox.utils.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 帅哥是我
 * @since 2022-08-03
 */
@RestController
@RequestMapping("/m-comment")
public class MCommentController {

    @Resource
    private MCommentServiceImpl mCommentService;


    /**
     * @api {POST} /m-comment/addComment 添加评价
     * @apiVersion 1.0.0
     * @apiGroup 评论控制器
     * @apiName addComment
     * @apiParam (请求参数) {String} token
     * @apiParamExample 请求参数示例
     * token=bHtl
     * @apiParam (请求体) {Number} mid
     * @apiParam (请求体) {Number} musicid
     * @apiParam (请求体) {Number} uid
     * @apiParam (请求体) {String} uname
     * @apiParam (请求体) {String} uinfo
     * @apiParam (请求体) {Number} goodcount
     * @apiParam (请求体) {String} uphoto
     * @apiParamExample 请求体示例
     * {"uid":3425,"uinfo":"TBZkhKZ","musicid":8885,"uname":"dkkAhDRRfR","goodcount":6366,"mid":9652,"uphoto":"smX0ekyc"}
     * @apiSuccess (响应结果) {Object} response
     * @apiSuccessExample 响应结果示例
     * {}
     */
    @PostMapping("/addComment")
    public Result addComment(@RequestBody MComment comment,@RequestHeader String token){
        return mCommentService.addComment(comment, token);
    }


    /**
     * @api {POST} /m-comment/addGoodCount 点赞评论
     * @apiVersion 1.0.0
     * @apiGroup 评论控制器
     * @apiName addGoodCount
     * @apiParam (请求参数) {String} token
     * @apiParamExample 请求参数示例
     * token=eLAd2
     * @apiParam (请求体) {Object} requestBody
     * @apiParamExample 请求体示例
     * {}
     * @apiSuccess (响应结果) {Object} response
     * @apiSuccessExample 响应结果示例
     * {}
     */
    @PostMapping("/addGoodCount")
    public Result addGoodCount(@RequestBody Map map,@RequestHeader String token)
    {
        Integer id = (Integer) map.get("id");
        return mCommentService.addGoodCount(id,token);
    }

}

